package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbMemberRecords;
import com.ruoyi.system.service.ITbMemberRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员权益使用记录表Controller
 * 
 * @author ruoyi
 * @date 2024-05-18
 */
@RestController
@RequestMapping("/business/records")
public class TbMemberRecordsController extends BaseController
{
    @Autowired
    private ITbMemberRecordsService tbMemberRecordsService;

    /**
     * 查询会员权益使用记录表列表
     */
    @PreAuthorize("@ss.hasPermi('business:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMemberRecords tbMemberRecords)
    {
        startPage();
        List<TbMemberRecords> list = tbMemberRecordsService.selectTbMemberRecordsList(tbMemberRecords);
        return getDataTable(list);
    }

    /**
     * 导出会员权益使用记录表列表
     */
    @PreAuthorize("@ss.hasPermi('business:records:export')")
    @Log(title = "会员权益使用记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMemberRecords tbMemberRecords)
    {
        List<TbMemberRecords> list = tbMemberRecordsService.selectTbMemberRecordsList(tbMemberRecords);
        ExcelUtil<TbMemberRecords> util = new ExcelUtil<TbMemberRecords>(TbMemberRecords.class);
        util.exportExcel(response, list, "会员权益使用记录表数据");
    }

    /**
     * 获取会员权益使用记录表详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:records:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbMemberRecordsService.selectTbMemberRecordsById(id));
    }

    /**
     * 新增会员权益使用记录表
     */
    @PreAuthorize("@ss.hasPermi('business:records:add')")
    @Log(title = "会员权益使用记录表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMemberRecords tbMemberRecords)
    {
        return toAjax(tbMemberRecordsService.insertTbMemberRecords(tbMemberRecords));
    }

    /**
     * 修改会员权益使用记录表
     */
    @PreAuthorize("@ss.hasPermi('business:records:edit')")
    @Log(title = "会员权益使用记录表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMemberRecords tbMemberRecords)
    {
        return toAjax(tbMemberRecordsService.updateTbMemberRecords(tbMemberRecords));
    }

    /**
     * 删除会员权益使用记录表
     */
    @PreAuthorize("@ss.hasPermi('business:records:remove')")
    @Log(title = "会员权益使用记录表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbMemberRecordsService.deleteTbMemberRecordsByIds(ids));
    }
}
